﻿using System;
using System.Collections.Generic;
using System.Net;
using System.Net.NetworkInformation;
using System.Web;

namespace Credinka.Ayni.GEN.UTL
{
    public class utlAuditoria
    {

        public static string ObtenerUsuarioDominio()
        {
            return (Environment.UserName);
        }

        public static string ObtenerNombreEquipo()
        {
            return (Dns.GetHostName());
        }

        public static string ObtenerDireccionIP()
        {
            string sIpEquipo = "";
            string sNombreEquipo;
            sNombreEquipo = Dns.GetHostName();
            IPHostEntry oHost = Dns.GetHostEntry(sNombreEquipo);
            foreach (IPAddress ip in oHost.AddressList)
            {
                if (ip.AddressFamily.ToString() == "InterNetwork")
                {
                    sIpEquipo = ip.ToString();
                    break;
                }
            }
            return (sIpEquipo);
        }

        public static string ObtenerDireccionMAC()
        {
            string macAddresses = string.Empty;

            foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces())
            {
                if (nic.OperationalStatus == OperationalStatus.Up)
                {
                    macAddresses += nic.GetPhysicalAddress().ToString();
                    break;
                }
            }

            return (macAddresses);
        }
    }
}